package com.zwz.utils;

import com.zwz.entity.CourtAnnouncement;
import com.zwz.resp.maininfo.JudicialCaseResponse;

import java.util.LinkedList;
import java.util.Queue;

public class ObjectPool {
    public  Queue<CourtAnnouncement> pool = new LinkedList<>();

    public ObjectPool(Queue<CourtAnnouncement> pool) {
        this.pool = pool;
    }

    public CourtAnnouncement acquire() {
        CourtAnnouncement obj = pool.poll();
        if (obj == null) {
            obj = new CourtAnnouncement(); // 池为空时创建新对象
        }
        return obj;
    }

    public void release(CourtAnnouncement obj) {
        pool.offer(obj); // 对象放回池中
    }
}